import axios from '@/libs/api.request'
import {
  format
} from 'path';
import {
  getToken,
  URL
} from "@/libs/util";

// 以防命名冲突
const HOST = URL

/**
 * @param {*} token
 * @param {*} formData  数据
 * @param {*} objKey    对象的KEY
 * @returns
 */

// 重点工作考评
function importantWorkData(formData, keyOne) {
  let data = {}
  data['tokenEntity'] = {
    value: getToken()
  }
  data[keyOne] = {
    id: formData.id,
    assessmentType: formData.assessmentType, // 考核类别
    checkObject: formData.checkObject, // 考核对象
    score: formData.score, // 分数
    assessmentOrder: formData.assessmentOrder, // 考核单号
    assessmentContent: formData.assessmentContent, // 考核内容
    assessmentTask: formData.assessmentTask, // 考核任务
    assessmentSource: formData.assessmentSource, // 考核来源
    pageSize: formData.pageSize, // 显示页数
    pageNumber: formData.pageNumber // 页码
  }
  return data
}
// 年度得分
function aunuScoreData(formData, keyOne) {
  let data = {}
  data['tokenEntity'] = {
    value: getToken()
  }
  data[keyOne] = {
    id: formData.id,
    datetime: formData.datetime, // 时间
    departcode: formData.deptCode, // 单位名称
    score: formData.score, // 总分
    industryScore: formData.industryScore, // 指标得分
    testScore: formData.testScore, // 测评得分
    implementationScore: formData.implementationScore, // 落实得分
    organsScore: formData.organsScore, // 机关党建得分
    grabScore: formData.grabScore, // 抓促得分
    visitScore: formData.visitScore, // 察访核验
    pageSize: formData.pageSize, // 显示页数
    pageNumber: formData.pageNumber // 页码
  }
  return data
}
// 重点工作考评
export const importantWorkAjax = ({
  formData,
  url,
  keyOne
}) => {
  let data = ''
  data = importantWorkData(formData, keyOne)
  return axios.request({
    url: HOST + url,
    data,
    method: 'post'
  })
}

// 绩效考评得分
export const aunuScoreAjax = ({
  formData,
  url,
  keyOne
}) => {
  let data = ''
  data = aunuScoreData(formData, keyOne)
  return axios.request({
    url: HOST + url,
    data,
    method: 'post'
  })
}
